package xyz.jpcr.covid19app.Util;

import android.appwidget.AppWidgetManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

import xyz.jpcr.covid19app.CovidAppWidget;

public class ISendBroadcastUtil {
    private static ISendBroadcastUtil iSendBroadcastUtil = null;
    public static ISendBroadcastUtil getInstance() {
        if(iSendBroadcastUtil == null) {
            iSendBroadcastUtil = new ISendBroadcastUtil();
        }
        return iSendBroadcastUtil;
    }

    public void updateWidget(Context context) {
        Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, AppWidgetManager.getInstance(context).getAppWidgetIds(new ComponentName(context.getPackageName(), CovidAppWidget.class.getName())));
        context.getApplicationContext().sendBroadcast(intent);
    }
}
